package multithread;

import java.util.Scanner;

public class ThreadDemo5 {
    private volatile static int flag = 0;
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            while(flag==0){
                //循环体  啥也不写
            }
            System.out.println("t1 over");
        });

        Thread t2 = new Thread(()->{
            System.out.println("please enter flag:");
            Scanner sc = new Scanner(System.in);
            flag= sc.nextInt();
        });
        t1.start();
        t2.start();
    }
}
